//
//  YCLabel.m
//  Tool
//
//  Created by 唐可雄 on 2019/7/27.
//  Copyright © 2019 swustyc. All rights reserved.
//

#import "YCLabel.h"

@implementation YCLabel

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
    CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
    switch (self.textVerAlignment) {
        case YCTextVerAlignmentCenter:
            textRect.origin.y = (bounds.size.height - textRect.size.height) / 2.0;
            break;
        case YCTextVerAlignmentTop:
            textRect.origin.y = 0;
            break;
        case YCTextVerAlignmentBottom:
            textRect.origin.y = bounds.size.height - textRect.size.height;
            break;
    }
    return textRect;
}

- (void)drawTextInRect:(CGRect)rect {
    [super drawTextInRect:[self textRectForBounds:rect limitedToNumberOfLines:self.numberOfLines]];
}

@end
